package tool.keep;

import java.awt.AWTException;
import java.awt.Point;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.imageio.ImageIO;
import javax.swing.*;

import com.google.common.collect.Lists;

import net.lingala.zip4j.exception.ZipException;
import tool.dataType.ClientStruct;
import tool.paoshang.GameClient;
import tool.windows.struct.LPRECTlpRect;

public class Keeper {

	private static String password = "!wodemima";
	private static Robot robot;
	
	private static BufferedImage worldNoneChoose;
	private static BufferedImage worldAllChoose;

	public static Point mhClintSize = new Point(652,543);
	private static LPRECTlpRect xy = new LPRECTlpRect();
	public static int mhTitleHeight = 58;
	public static int mhBonder = 6;

	public static List<ClientStruct> threads = Lists.newArrayList();

	public static Point pywz = new Point(25,-3);
	public static Point pywzTop = new Point(25,-3);
	public static Point pywzBottom = new Point(25,5);
	public static int[][] npccolor = new int[][] {
		{-459552,-459560,-984896},
		{-459552,-984896,-460608},
		{-459568,-985928,-985936}};
	
	public static int npcColorTop[] = new int[] {-459552,-459568,-459560,-984896,-985928,-460608,-985936};
	public static int npcColorBottom[] = new int[] {-2042800,-1513368,-1514400,-1515432,-2572240,-3097552};
		
	public static Point xTop = new Point(592,294);
	public static Point xBottom = new Point(592,302);
	
	public static int dialogXTop[] = new int[] {-13609856,-13080440,-11504496,-11504504,-13083512,-10456992,-12043208};
	public static int dialogXBottom[] = new int[] {-13081464,-13080440,-13609856,-11504496,-13083512,-12028792};
	

	public static Point bjlzck = new Point(502,341);
	public static Point dtgjck = new Point(521,285);
	public static Point csjwck = new Point(476,341);
	public static Point dtjwck = new Point(396,359);
	public static Point cack = new Point(415,443);
	public static Point csck = new Point(423,341);
	public static int mapRightColor = -459528;
	public static int mapUnrRightColor = -12048352;
		
	public static int noProductColor= -4673320;
		
	public static enum product{
		
		棉布(3300,new int[][] {{-7308184,-8360872,-8888232},{-6781840,-7308184,-7835552},{-4674416,-5728120,-5729152}}),
		佛珠(8000,new int[][] {{-11596274,-8493994,-5195624},{-11533312,-8890304,-8363952},{-9420768,-11000824,-11003904}}),
		纸扇(5000,new int[][] {{-10470384,-10471416,-14131200},{-10478592,-12053504,-14659584},{-12055552,-13100032,-14649344}}),
		武器(5500,new int[][] {{-14802910,-12961980,-11843496},{-12961980,-11843496,-10330509},{-11843496,-9936006,-8028260}}),
		木料(4300,new int[][] {{-4159424,-4159424,-2582456},{-2582456,-2582456,-2055080},{-2581424,-3106744,-2582456}}),
		面粉(4000,new int[][] {{-4674424,-2037536,-1512216},{-2565936,-1513240,-2037536},{-1513240,-2039592,-2038560}}),
		鹿茸(9500,new int[][] {{-9937848,-9937848,-8362912},{-6258568,-6259592,-6260624},{-7310224,-6258560,-3616616}}),
		符(7000,new int[][] {{-10990536,-3090248,-986912},{-4145000,-1513256,-2565960},{-8886184,-5201832,-3623872}}),
		银票(0,new int[][] {{-3614504,-2037528,-1510160},{-1510160,-5720904,-4666160},{-2563872,-5195592,-8882056}}),
		珍珠(5800,new int[][] {{-5753824,-3655648,-5228512},{-4179936,-5228512,-7328736},{-5228512,-6803424,-8902632}}),
		首饰(4700,new int[][] {{-5068602,-2252159,-1011624},{-1336724,-2593712,-5158056},{-2599864,-5022358,-7304535}}),
		纸钱(3000,new int[][] {{-7303040,-8881032,-8881032},{-7302000,-8354688,-9406344},{-7302000,-8354688,-9931664}}),
		夜明珠(10000,new int[][] {{-4681608,-13081488,-13081488},{-9415616,-10465216,-4681624},{-16252928,-12577784,-15202304}}),
		盐(20000,new int[][] {{-984864,-1513264,-4675416},{-5196632,-10454920,-10454912},{-10980224,-9927536,-9926504}}),
		布帽(4000,new int[][] {{-12038064,-10985384,-10986408},{-10986408,-9934752,-10985384},{-10985384,-9407376,-10985384}}),
		酒(4800,new int[][] {{-10484728,-15728640,-16777216},{-12582912,-16777216,-16777216},{-15728640,-15728640,-15728640}}),
		蜡烛(2000,new int[][] {{-985904,-993104,-3104656},{-5733288,-2573168,-987976},{-6270936,-7324648,-4699104}}),
		铜铃(4500,new int[][] {{-12308203,-11055565,-7833528},{-11516888,-15199232,-15199232},{-5203872,-7833528,-9939928}}),
		人参(7800,new int[][] {{-5200816,-7309272,-9407384},{-3094424,-7309272,-7838680},{-2563976,-2567056,-5201840}}),
		香油(4000,new int[][] {{-6254504,-6254504,-5727136},{-7306152,-10465240,-12043232},{-3618688,-3618688,-7306160}}),
		背包银票(0,new int[][] {{-4140848,-3614504,-2037528},{-3087128,-1510160,-5720904},{-2563880,-2563872,-5195592}}),
		摄妖香(0,new int[][] {{-7106976,-6775712,-6775712},{-8028258,-8817522,-8817266},{-5791546,-5791546,-5791545}});
		
		private product(Integer price,int[][] color) {
			this.price = price;
			this.color = color;
		}
		private Integer price;
		private int[][] color;
		public Integer getPrice() {
			return price;
		}
		public int[][] getColor(){
			return color;
		}
	}
		
	private static void init(){
		try {
			Keeper.robot = new Robot();
		} catch (AWTException e) {
			e.printStackTrace();
		}
		initImage();
		initRect();
	}
	public static enum startPosition{
		x1(0),x2(8),x3(16),y1(41),y2(49),y3(57);
		private int position;
		private startPosition(int position) {
			this.position = position;
		}
		public int getPosition() {
			return position;
		}
	}

	public static enum NumberPoints {
		one(1,new int[] {0,0,2,2,9,1,1,0}),
		two(2,new int[] {0,0,4,2,2,3,5,0}),
		three(3,new int[] {0,0,4,1,2,2,7,0}),
		four(4,new int[] {0,0,2,3,3,9,2,0}),
		five(5,new int[] {0,0,6,2,2,2,5,0}),
		six(6,new int[] {0,6,3,2,2,3,5,0}),
		sever(7,new int[] {0,0,1,0,5,3,1,0}),
		eight(8,new int[] {0,6,3,2,2,3,6,0}),
		nine(9,new int[] {0,4,2,2,2,3,6,0}),
		zero(0,new int[] {0,6,2,1,1,2,6,0});
		private int[] whiteNumber;
		private int number;
		private NumberPoints(int number,int[] whiteNumber) {
			this.number=number;
			this.whiteNumber = whiteNumber;
		}
		public int[] getWhiteNumber() {
			return whiteNumber;
		}
		public int getNumber() {
			return number;
		}
	}

	public static int colorblack = -16776961;
	public static int colorblue = -16777216;
	public static int colorgreen = -16736512;
	public static enum jyNumberPoints {
		one(1,new int[] {1,3,1,1,1,1,1,1,1,5}),
		two(2,new int[] {3,2,2,1,1,1,1,1,2,5}),
		three(3,new int[] {3,2,2,1,2,1,1,2,2,3}),
		four(4,new int[] {1,1,2,2,2,2,5,1,1,3}),
		five(5,new int[] {5,1,1,4,2,1,1,2,2,3}),
		six(6,new int[] {2,2,1,4,3,2,2,2,2,3}),
		sever(7,new int[] {5,2,1,1,1,1,1,1,1,1}),
		eight(8,new int[] {4,2,2,2,4,2,2,2,2,4}),
		nine(9,new int[] {3,2,2,2,3,4,1,1,2,2}),
		zero(0,new int[] {2,2,2,2,2,2,2,2,2,2});
		private int[] jyNumber;
		private int number;
		private jyNumberPoints(int number,int[] whiteNumber) {
			this.number=number;
			this.jyNumber = whiteNumber;
		}
		public int[] getJyNumber() {
			return jyNumber;
		}
		public int getNumber() {
			return number;
		}
	}
	
	private static void initRect() {
		
		xy.x=43;
		xy.y=124;
		xy.width=65;
		xy.height=9;
	}

	public static void main(String args[]){
		initImage();
	}

	public static void initImage() {
		try {
			try {
				File[] files = GameClient.unzip("o.zip","!wodemima");
				worldNoneChoose = ImageIO.read(files[0]);
				worldAllChoose = ImageIO.read(files[1]);
				files[0].delete();
				files[1].delete();
			} catch (ZipException e) {
				JOptionPane.showMessageDialog(null,"请以管理员方式启动！");
				System.exit(0);
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static Robot getRobot() {
		if(robot == null) init();
		return robot;
	}
	
	public static BufferedImage getWorldNoneChoose() {
		if(worldNoneChoose == null) init();
		return worldNoneChoose;
	}
	public static BufferedImage getWorldAllChoose() {
		if(worldAllChoose == null) init();
		return worldAllChoose;
	}

	public static LPRECTlpRect getXy() {
		if(xy.x==0){
			init();
		}
		return xy;
	}
	
}
